import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/view/Login'
import Main from '@/view/Main'
import Menu from '@/view/Menu'
import Content from '@/view/Content'
import Add from '@/view/Add'
import Result from '@/view/Result'
import Success from '@/view/Success'

Vue.use(Router)

export default new Router({
  // mode: 'history',
  routes: [{
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/',
      name: 'Main',
      component: Main,
      meta: {
        requireAuth: true, // 添加该字段，表示进入这个路由是需要登录的
      },
    },
    {
      path: '/menu',
      name: 'Menu',
      component: Menu
    },
    {
      path: '/content/:voteId',
      name: 'Content',
      component: Content,
      props: true,
      meta: {
        requireAuth: true, // 添加该字段，表示进入这个路由是需要登录的
      },
    },
    {
      path: '/add',
      name: 'Add',
      component: Add,
      meta: {
        requireAuth: true, // 添加该字段，表示进入这个路由是需要登录的
      },
    },
    {
      path: '/result/:voteId',
      name: 'Result',
      component: Result,
      props: true,
      meta: {
        requireAuth: true, // 添加该字段，表示进入这个路由是需要登录的
      },
    },
    {
      path: '/success',
      name: 'Success',
      component: Success,
      meta: {
        requireAuth: true, // 添加该字段，表示进入这个路由是需要登录的
      },
    }
  ]
})
